{template 'public/header'}
{template 'public/comhead'}
{if $operation != 'newpassword'}
<ul class="nav nav-tabs">
    <li {if $operation == 'display' || empty($operation)}class="active"{/if}><a href="{php echo $this->createWebUrl('marketing', array('op' => 'display'))}">市场专员管理</a></li>
    <li {if $operation == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('marketing', array('op' => 'post'))}">添加市场专员</a></li>
    <li><a href="{php echo $this->createWebUrl('marketinglevel', array('op' => 'display'))}">专员等级管理</a></li>
    <li><a href="{php echo $this->createWebUrl('marketinglevel', array('op' => 'post'))}">添加专员等级</a></li>
    <li {if $operation == 'log'}class="active"{/if}><a
        href="{php echo $this->createWebUrl('marketing', array('op' => 'log'))}">提现管理</a></li>
</ul>
{/if}
{if $operation == 'display'}
<div class="main">
    <div class="panel panel-default">
        <div class="table-responsive panel-body">
        <form action="" method="post" class="form-horizontal form" >
            <input type="hidden" name="storeid" value="{$storeid}" />
            <table class="table table-hover">
                <thead class="navbar-inner">
                <tr>
                    <th style="width:20%;">编号</th>
                    <th style="width:15%;">所属等级</th>
                    <th style="width:15%;">姓名</th>
                    <th style="width:15%;">手机</th>
                    <th style="width:15%;">门店数量</th>
                    <th style="width:20%;text-align:right;">操作</th>
                </tr>
                </thead>
                <tbody id="level-list">
                {loop $list $row}
                <tr>
                    <td>{$row['id']}</td>
                    <td>{$levellist[$row['levelid']]['title']}</td>
                    <td>{$row['username']}</td>
                    <td>{$row['mobile']}</td>
                    <td>{$row['storetotal']}</td>
                    <td style="text-align:right;">
                        <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('marketing', array('op' => 'post', 'id' => $row['id'], 'storeid' => $storeid))}" title="编辑"><i class="fa fa-pencil"> 改</i></a>
                        <a class="btn btn-default btn-sm" onclick="return confirm('确认删除吗？');return false;"
                           href="{php echo $this->createWebUrl('marketing', array('id' => $row['id'], 'op' => 'delete'))}" title="删除">删</a>
                    </td>
                </tr>
                <tr>
                    <td>商家入驻链接:</td>
                    <td colspan="5">{$_W['siteroot']}{php echo "app/" . $this->createMobileUrl('addstore', array('marketingid' =>$row['id']), true)}</td>
                </tr>
                <tr>
                    <td>专员链接:</td>
                    <td colspan="5">{$_W['siteroot']}{php echo "app/" . $this->createMobileUrl('marketing', array(), true)}</td>
                </tr>
                {/loop}
                </tbody>
            </table>
        </form>
        {$pager}
        </div>
    </div>
</div>
{elseif $operation == 'post'}
<link rel="stylesheet" href="{$_W['siteroot']}addons/weisrc_dish/public/web/css/awesome-bootstrap-checkbox.css">
<div class="main">
    <script type="text/javascript">
        require(['jquery', 'util'], function($, u){
            $('#form1').submit(function(e) {
                if($.trim($(':text[name="username"]').val()) == '') {
                    u.message('没有输入用户名.', '', 'error');
                    return false;
                }
            });
        });
    </script>
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" id="form1">
        <input type="hidden" name="parentid" value="{$parent['id']}" />
        <div class="panel panel-default">
            <div class="panel-heading">
                添加新用户
            </div>
            <div class="panel-body">
                {if $marketing}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">入驻二维码</label>
                    <div class="col-sm-9">
                        {php $url = $_W['siteroot'] ."app/" . $this->createMobileUrl('addstore', array('marketingid'=>$marketing['id']),true)}
                        <img src="{php echo $this->createWebUrl('GetQrcode',array('url'=>$url))}"/>
                    </div>
                </div>
                {/if}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">*</span>微信昵称</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class="input-group">
                            <input type="text" name="nickname" value="{$fans['nickname']}" class="form-control" readonly="">
                            <input type="hidden" name="from_user" value="{$marketing['from_user']}">
                        <span class="input-group-btn">
				            <button class="btn btn-default" type="button" onclick="$('#modal-module-menus').modal();" data-original-title="" title="">选择粉丝</button>
			            </span>
                        </div>
                        <div class="input-group cover" style="margin-top:.5em;">
                            <img src="{php echo tomedia($fans['headimgurl']);}" width="150" />
                        </div>
                        <div class="help-block">手机端管理订单，接收订单通知。</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">所属等级</label>
                    <div class="col-sm-10 col-lg-9">
                        <select class="form-control" name="levelid" id="levelid">
                            <option value="0">请选择等级</option>
                            {loop $levellist $row}
                            <option value="{$row['id']}" {if $marketing['levelid']==$row['id'] }selected{/if}>{$row['title']}</option>
                            {/loop}
                        </select>
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">真实姓名</label>
                    <div class="col-sm-10 col-lg-9">
                        <input type="text" name="username" class="form-control" value="{$marketing['username']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">手机号码</label>
                    <div class="col-sm-10 col-lg-9">
                        <input type="text" name="mobile" class="form-control" value="{$marketing['mobile']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">所属银行</label>
                    <div class="col-sm-10 col-lg-9">
                        <input type="text" name="bankname" class="form-control" value="{$marketing['bankname']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">银行卡号</label>
                    <div class="col-sm-10 col-lg-9">
                        <input type="text" name="bankcard" class="form-control" value="{$marketing['bankcard']}" />
                    </div>
                </div>

            </div>
        </div>
        <div class="form-group col-sm-12">
            <input type="submit" name="submit" value="保存设置" class="btn btn-primary col-lg-3" />
            <input type="hidden" name="token" value="{$_W['token']}" />
        </div>
    </form>
</div>
{template 'web/_modal_fans'}
{elseif $operation == 'log'}
<div class="main">
    <div class="alert alert-info">
        <h4>
            <i class="fa fa-info-circle"></i>
            说明:提现需要管理员手动打款，打款后标记对应的提现申请处理成功!
        </h4>
        <p style="color: red">&nbsp;&nbsp;&nbsp;&nbsp;商户结算数据涉及钱款操作，请认真审核，谨慎操作！</p>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <form action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="weisrc_dish" />
                <input type="hidden" name="do" value="business" />
                <input type="hidden" name="op" value="adminbusinesslog" />
                <input type="hidden" name="status" value="{$_GPC['status']}" />
                <input type="hidden" name="business_type" value="{$_GPC['business_type']}" />
                <div class="form-group" style="margin-left: 40px">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">提现状态</label>
                    <div class="col-sm-8 col-lg-10 col-xs-12">
                        <div class="btn-group">
                            <a href="{php echo $this->createWebUrl('marketing', array('op' => 'log'))}" class="btn {if $_GPC['status'] == ''}btn-primary{else}btn-default{/if}" style="width: 80px">不限</a>
                            <a href="{php echo $this->createWebUrl('marketing', array('op' => 'log', 'status' => 0))}"
                               class="btn {if $_GPC['status'] == 0 && isset($_GPC['status']) && $_GPC['status'] != ''}btn-primary{else}btn-default{/if}">待处理</a>
                            <a href="{php echo $this->createWebUrl('marketing', array('op' => 'log', 'status' => 1))}" class="btn {if $_GPC['status'] == 1}btn-primary{else}btn-default{/if}">已提现</a>
                            <a href="{php echo $this->createWebUrl('marketing', array('op' => 'log', 'status' => -1))}" class="btn {if $_GPC['status'] == -1}btn-primary{else}btn-default{/if}">提现失败</a>
                        </div>
                    </div>
                </div>
                <div class="form-group" style="margin-left: 40px">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" >下单时间</label>
                    <div class="col-sm-7 col-lg-3 col-xs-12">
                        <div class="input-group-btn">
                            {php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d', $starttime),'endtime'=>date('Y-m-d', $endtime)));}
                            <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                            <button class="btn btn-success" name="out_put" value="output"><i class="fa fa-file"></i> 导出</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <form action="" method="post" class="form-horizontal form">
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="row-fluid">
                    <div class="span3 control-group">
                        佣金管理
                    </div>
                </div>
            </div>
            <div class="table-responsive panel-body">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width:15%;">(ID)申请时间</th>
                        <th style="width:10%;">提现金额</th>
                        <th style="width:23%;">账号信息</th>
                        <th style="width:10%;">状态</th>
                        <th style="width:10%;">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $list $item}
                    <tr>
                        <td>
                            ({$item['id']})
                            {php echo date("Y-m-d H:i:s", $item['dateline'])}
                            {if $item['business_type']== 1 && $item['status'] == 1}
                            <br/>
                            <span class="label label-success">商户单号:{$item['trade_no']}</span>
                            <br/>
                            <span class="label label-success">微信单号:{$item['payment_no']}</span>
                            {/if}
                        </td>
                        <td>
                            {$item['price']}元
                        </td>
                        <td>

                            所属银行:{$item['bankname']}<br/>
                            银行卡号:{$item['bankcard']}<br/>
                        </td>
                        <td>
                            {if $item['status'] == 1}
                            <span class="label label-success">已提现</span>
                            {elseif $item['status'] == -1}
                            <span class="label label-danger">提现失败</span>
                            <br/>
                            {$item['result']}
                            {else}
                            <span class="label label-danger">待审核</span>
                            {/if}
                        </td>
                        <td>
                            {if $item['status'] == 0}
                            <a class="btn btn-success btn-sm" href="{php echo $this->createWebUrl('marketing', array('id' => $item['id'], 'op' => 'setstatus', 'sess_id' => $sess_id))}" title="管理" onclick="return confirm('确认操作吗？');return false;"> 审核</a>
                            <a class="btn btn-danger btn-sm" href="{php echo $this->createWebUrl('marketing', array('id' => $item['id'], 'op' => 'delete'))}" title="删除" onclick="return confirm('确认操作吗？');return false;"> 删除</a>
                            {/if}
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
                {$pager}
            </div>
        </div>
    </form>
</div>
{/if}
{if $_W['isfounder']}
{template 'common/footer'}
{else}
{template 'public/footer'}
{/if}